import { R_tableData, R_add, R_update, R_remove } from "@/utils/tableData";



import request from '@/utils/request'

export const A_tableData = function(data) {
    return R_tableData({
        method: 'post',
        url: '/SciWriter/list',
        data,
    })
}


export const A_add = function(data) {
    return R_add({
        method: 'post',
        url: '/SciWriter/add',
        data
    })
}


export const A_update = function(data) {
    return R_update({
        method: 'post',
        url: '/SciWriter/update',
        data
    })
}

export const A_remove = function(ID) {
    return R_remove({
        method: 'post',
        url: '/SciWriter/delete',
        data: {
            writerKey: ID
        }
    })
}


export const A_check_T = async function(data) {
    let result = await request({
        method: 'post',
        url: '/SciWriter/Tshen',
        data,
    })
    return result
}


export const A_check_F = async function(data) {
    let result = await request({
        method: 'post',
        url: '/SciWriter/Nshen',
        data,
    })
    return result
}

/**
 * 下载表格
 * @param {*} data 
 * @returns 
 */
export const A_downLoadExcel = async function() {
    let res = await request({
        method: 'post',
        url: '/SciWriter/downloadExcel',
        headers: {
            "Content-Type": 'application/octet-stream;charset=UTF-8'
        },
        responseType: 'blob'
    })
    return res
}

/**
 * 获取个人附件
 * @param {*} writerKey 唯一标识
 */
export const A_getFile = async function(writerKey) {
    let res = await request({
        method: 'post',
        url: '/SciWriter/Perfile',
        data: {
            writerKey
        }
    })
    return res
}

/**
 * 获取一级等级
 * @returns 
 */
export const A_getLevel1 = async function() {
    let res = await request({
        method: 'get',
        url: '/SciWriter/Level'
    })
    return res
}

export const A_downLoadExample = async function() {
    let res = await request({
        method: 'get',
        url: '/SciWriter/downloadExcelExample',
        headers: {
            "Content-Type": 'application/octet-stream;charset=UTF-8'
        },
        responseType: 'blob'
    })
    return res
}